//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "DonutStatistic.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <fstream>
#include <iostream>
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#define MAX_SIZE 500000
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DonutStatistic::DonutStatistic () {

  this->level                 = new String ();
  this->totalPercentagePie    = 0;
  this->totalPercentage       = 0;
  this->partialPercentagePie  = 0;
  this->partialPercentage     = 0;

  this->toString              = new String ();

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DonutStatistic::DonutStatistic (const DonutStatistic& donutStatistic) {

  this->level                 = new String (donutStatistic.level);
  this->totalPercentagePie    = donutStatistic.totalPercentagePie;
  this->totalPercentage       = donutStatistic.totalPercentage;
  this->partialPercentagePie  = donutStatistic.partialPercentagePie;
  this->partialPercentage     = donutStatistic.partialPercentage;

  this->toString              = new String (donutStatistic.toString);

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DonutStatistic::DonutStatistic (const DonutStatistic* donutStatistic) {

  this->level                 = new String (donutStatistic->level);
  this->totalPercentagePie    = donutStatistic->totalPercentagePie;
  this->totalPercentage       = donutStatistic->totalPercentage;
  this->partialPercentagePie  = donutStatistic->partialPercentagePie;
  this->partialPercentage     = donutStatistic->partialPercentage;

  this->toString              = new String (donutStatistic->toString);

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DonutStatistic::~DonutStatistic () {

  if (this->level)    delete this->level;
  if (this->toString) delete this->toString;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DonutStatistic::Level (String* level) {

  if (level)
    *(this->level) = *level;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DonutStatistic::TotalPercentagePie (float totalPercentagePie) {

  this->totalPercentagePie = totalPercentagePie;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DonutStatistic::TotalPercentage (float totalPercentage) {

  this->totalPercentage = totalPercentage;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DonutStatistic::PartialPercentagePie (float partialPercentagePie) {

  this->partialPercentagePie = partialPercentagePie;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DonutStatistic::PartialPercentage (float partialPercentage) {

  this->partialPercentage = partialPercentage;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

String* DonutStatistic::Level (void) {

  return this->level;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
float DonutStatistic::TotalPercentagePie (void) {

  return this->totalPercentagePie;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
float DonutStatistic::TotalPercentage (void) {

  return this->totalPercentage;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
float DonutStatistic::PartialPercentagePie (void) {

  return this->partialPercentagePie;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
float DonutStatistic::PartialPercentage (void) {

  return this->partialPercentage;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* DonutStatistic::ToString (void) {

  char buffer[MAX_SIZE];
  
  sprintf(buffer, "%s,%.4f,%.4f,%.4f,%.4f\0", this->level->Out(), 
                                              this->partialPercentage, 
                                              this->partialPercentagePie, 
                                              this->totalPercentage, 
                                              this->totalPercentagePie);
  this->toString->In(buffer);
  
  return this->toString;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DonutStatistic DonutStatistic::operator= (const DonutStatistic& donutStatistic) {

  *(this->toString)           = *(donutStatistic.toString);
  *(this->level)              = *(donutStatistic.level);
  this->totalPercentagePie    = donutStatistic.totalPercentagePie;
  this->totalPercentage       = donutStatistic.totalPercentage;
  this->partialPercentagePie  = donutStatistic.partialPercentagePie;
  this->partialPercentage     = donutStatistic.partialPercentage;

  return *this;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
